package com.neuedu.his.dao;

import com.neuedu.his.entity.RegisterLevel;
import com.neuedu.his.framework.BaseDao;
import com.neuedu.util.JDBCUtil;

import java.util.List;

/**
 * 项目：      his
 * 类名:       RoleDao
 * 创建时间：  2020/12/23  8:43
 * 描述 :     用户数据访问层
 * 作者 :     张金山
 * QQ :     314649444
 * Site:      https://jshand.gitee.io
 */
public class RegisterLevelDao implements BaseDao<RegisterLevel> {


    @Override
    public List<RegisterLevel> selectList(String sql, Object... args) {
        return JDBCUtil.executeQuery(sql, RegisterLevel.class, args);
    }

    @Override
    public RegisterLevel selectById(Integer id) {
        String sql = " select * from regist_level where id = ?";
        return JDBCUtil.getOne(sql, RegisterLevel.class, id);
    }

    @Override
    public boolean update(RegisterLevel registerLevel) {

        StringBuffer sql = new StringBuffer();
        sql.append(" UPDATE 						");
        sql.append("   regist_level                     ");
        sql.append(" SET                            ");
        sql.append("    name  				= ?,    ");
        sql.append("    fee 				= ?    ");


        sql.append(" WHERE  id 		 = ?            ");

        return JDBCUtil.executeUpdate(sql.toString(),
                registerLevel.getName(),
                registerLevel.getFee(),
                registerLevel.getId()
        );
    }


    /**
     * 逻辑删除，没有真正删除数据
     *
     * @param id
     * @return
     */
    @Override
    public boolean deleteById(Integer id) {

        String sql = " update  regist_level set active = 0 where id  = ? ";

        return JDBCUtil.executeUpdate(sql, id);
    }

    @Override
    public boolean batchDel(String sql, Object... parm) {
        return false;
    }

    @Override
    public boolean insert(RegisterLevel registerLevel) {
        String sql = " INSERT INTO regist_level (   name,     fee   )  VALUES   ( ?,? ) ";
        return JDBCUtil.executeUpdate(sql,
                registerLevel.getName(),
                registerLevel.getFee()
        );
    }

}
